<template>
  <view>
    <view class="overClass" v-if="filterLists.length" style="max-height: 100vh">
      <view v-for="item in filterLists" :key="item.id">
        <view class="wrapBox">
          <view class="smallBox">
            <text class="maxwidth"> 危废行业俗称:{{ item.wfTypeName }} </text>
            <text> 部门:{{ item.deptName }} </text>
          </view>
          <view class="smallBox">
            <text> 已转运:{{ item.wfTypeWeight }} </text>
            <text> 转运日期:{{ item.planTransTime }} </text>
          </view>
          <view class="smallBox">
            <text> 申请人:{{ item.userName }} </text>
          </view>
          <view class="flex-end">
            <button
              @click="handleLook(item)"
              class="commonBtnClass"
              :disabled="item.lookDisabled"
              :loading="item.lookDisabled"
              style="width: 200rpx"
            >
              查看转运单33
            </button>
            <button
              @click="handleDown(item)"
              class="commonBtnClass"
              :disabled="item.downDisabled"
              :loading="item.downDisabled"
              style="width: 200rpx"
            >
              下载转运单
            </button>
            <button
              @click="handleDetails(item)"
              class="commonBtnClass"
              style="width: 160rpx"
            >
              查看详情
            </button>
          </view>
        </view>
      </view>
    </view>
    <view v-else class="loadingClass"> 暂无数据 </view>
  </view>
</template>

<script setup>
import { basePDFURL } from "@/utils";
import { useMemberStore } from "@/stores/modules/member";
import { notice_down_pdf, show_trans_pdf } from "@/commonApi";
const props = defineProps(["value"]);
const memberStore = useMemberStore();
const filterLists = ref([]);
onShow(() => {
  if (memberStore.searchLists[1]) {
    filterLists.value = memberStore.searchLists[1][props.value];
  }
});
const handleLook = async (item) => {
  try {
    item.lookDisabled = true;
    await show_trans_pdf(item.applyId, encodeURIComponent(item.wfTypeName));
  } catch (err) {
    memberStore.srcURL = `${basePDFURL}/trans_pdf/${
      item.transCode
    }-${encodeURIComponent(item.wfTypeName)}.pdf`;
    uni.navigateTo({
      url: `/pages/PdfShow/PdfShow`,
    });
  } finally {
    item.lookDisabled = false;
  }
};
const handleDetails = (item) => {
  memberStore.QueryTransferDetails = item;
  uni.navigateTo({
    url: `/pages/QueryTransferDetails/QueryTransferDetails`,
  });
};
const handleDown = async (item) => {
  try {
    item.downDisabled = true;
    await notice_down_pdf(
      item.applyId,
      encodeURIComponent(item.wfTypeName),
      memberStore.userInfo.userIdDing
    );
    item.downDisabled = false;
    uni.showToast({ icon: "success", title: "下载成功" });
  } catch (err) {
    item.downDisabled = false;
  }
};
</script>

<style lang="scss" scoped>
</style>